//
//  SetLogonViewController.m
//  EggSteward
//
//  Created by 王道林 on 16/9/14.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "SetLogonViewController.h"
#import "BaseTableView.h"
#import "SetTableViewCellO.h"
#import "BaseButton.h"
#import "FeedBackViewController.h"
#import "AboutUsViewController.h"
#import "LogonViewController.h"

@interface SetLogonViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) BaseTableView *tableView;
@property (nonatomic, strong) NSMutableArray *arr;
@end

@implementation SetLogonViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    _arr = [NSMutableArray arrayWithObjects:@"意见反馈", @"关于我们", nil];
    [self createSubView];
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:self action:nil];
    self.tabBarController.tabBar.hidden = NO;
    self.navigationItem.title = @"设置";
}

- (void)createSubView
{
    _tableView = [[BaseTableView alloc] initWithFrame:CGRectMake(0, -35, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];
    _tableView.bounces = NO;
    [self tableViewFoorView];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    [_tableView registerClass:[SetTableViewCellO class] forCellReuseIdentifier:@"reuse"];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _arr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SetTableViewCellO *cell = [tableView dequeueReusableCellWithIdentifier:@"reuse" forIndexPath:indexPath];
    cell.labelTitle.text = _arr[indexPath.row];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}
// 创建tableView的FooterView
- (void)tableViewFoorView
{
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 100)];
    _tableView.tableFooterView = view;
    BaseButton *button = [BaseButton buttonWithType:UIButtonTypeSystem];
    [view addSubview:button];
    button.frame = CGRectMake(20, 10, self.view.frame.size.width - 40, 50);
    button.backgroundColor = [UIColor colorWithRed:0.157 green:0.651 blue:0.278 alpha:1.000];
    [button setTitle:@"登录" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonLogonAction:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)buttonLogonAction:(BaseButton *)button
{
    LogonViewController *logonVC = [[LogonViewController alloc] init];
    logonVC.setlogon = @"setlogon";
    [self.navigationController pushViewController:logonVC animated:YES];
}

#pragma mark - 点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        FeedBackViewController *feedBackVC = [[FeedBackViewController alloc] init];
        [self.navigationController pushViewController:feedBackVC animated:YES];
    }else{
        AboutUsViewController *aboutVC = [[AboutUsViewController alloc] init];
        [self.navigationController pushViewController:aboutVC animated:YES];
    }
}





#pragma mark - 点击cell的时候有颜色显示
- (void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath
{
    SetTableViewCellO *cell = [tableView cellForRowAtIndexPath:indexPath];
    cell.backgroundColor = [UIColor colorWithRed:0.886 green:1.000 blue:0.066 alpha:1.000];
}

- (void)tableView:(UITableView *)tableView didUnhighlightRowAtIndexPath:(NSIndexPath *)indexPath
{
    SetTableViewCellO *cell = [tableView cellForRowAtIndexPath:indexPath];
    cell.backgroundColor = [UIColor whiteColor];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
